package com.zhuss.juc;

import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;

public class Test01 {
	
	public static void main(String[] args) throws InterruptedException {
		A a = new A();
		for (int j = 0; j < 100; j ++) {
			new Thread(()-> {
				for (int i = 0; i < 1000; i++) { 
					try {
					} catch (Exception e) {
						e.printStackTrace();
					}
					a.list.add(1);
				}
			}).start();
		}
		
		
		for (;;) {
			Thread.sleep(1000);
			System.out.println(a.list.size());
		}
	}

}

class A {
	List<Integer> list = new CopyOnWriteArrayList<>();
	
	int i = 0;
}
